<?php
namespace app\admin\validate;

use think\Validate;

/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2016/5/7
 * Time: 17:28
 */
class StudentValidate extends Validate
{
    protected $rule = [
        'relname' => 'require|max:20',
        'username' => 'require|max:11|min:11|checkphone:1',
        'majorid' => 'require',
    ];
    protected $message = [
        'relname.require' => '姓名必须填写',
        'relname.max' => '姓名最多不能超过5个字',
        'username.require' => '电话必须填写',
        'username.max' => '电话最多不能超过11位',
        'username.min' => '电话最低不能少于11位',
        'username.checkphone' => '请填写正确的手机号码格式',
        'majorid.require' => '专业不能为空',
    ];
    protected function checkphone($value,$rule)
    {
        return preg_match("/^[1][3578][0-9]{9}$/",$value) == $rule;
    }
}